| Total Complexity | 2 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 16 | |||
| 17 | @Controller('activities') |
||
| 18 | @ApiUseTags('Activity') |
||
| 19 | @ApiBearerAuth() |
||
| 20 | @UseGuards(AuthGuard('bearer')) |
||
| 21 | export class DeleteActivityAction { |
||
| 22 | constructor( |
||
| 23 | @Inject('ICommandBus') |
||
| 24 | private readonly commandBus: ICommandBus, |
||
| 25 | ) {} |
||
| 26 | |||
| 27 | @Delete(':id') |
||
| 28 | @ApiOperation({title: 'Delete activity'}) |
||
| 29 | public async index( |
||
| 30 | @Param() deleteActivityDto: DeleteActivityDTO, |
||
| 31 | @LoggedUser() user: User |
||
| 32 | ): Promise<any> { |
||
| 33 | try { |
||
| 34 | const {id: activityId} = deleteActivityDto; |
||
| 35 | const id = await this.commandBus.execute( |
||
| 36 | new DeleteActivityCommand(user, activityId) |
||
| 37 | ); |
||
| 38 | |||
| 39 | return true; |
||
| 40 | } catch (e) { |
||
| 41 | throw new BadRequestException(e.message); |
||
| 42 | } |
||
| 45 |